home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / pminfo.z / pminfo
Encoding:
Text File  |  2002-10-03  |  9.5 KB  |  265 lines

  1.  
  2.  
  3.  
  4. ppppmmmmiiiinnnnffffoooo((((3333))))                                                            ppppmmmmiiiinnnnffffoooo((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      __pm_get_page_info, __mld_to_node - retrieve placement information
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ppppmmmmoooo....hhhh>>>>
  14.  
  15.      ttttyyyyppppeeeeddddeeeeffff   ssssttttrrrruuuucccctttt ppppmmmm____ppppggggiiiinnnnffffoooo____ssss {{{{
  16.           ccccaaaaddddddddrrrr____tttt vvvvaaaaddddddddrrrr;;;;
  17.           ddddeeeevvvv____tttt     nnnnooooddddeeee____ddddeeeevvvv;;;;
  18.           uuuuiiiinnnntttt ppppaaaaggggeeee____ssssiiiizzzzeeee;;;;
  19.           ppppmmmmoooo____hhhhaaaannnnddddlllleeee____tttt ppppmmmm____hhhhaaaannnnddddlllleeee;;;;
  20.              vvvvooooiiiidddd****   rrrreeeesssseeeerrrrvvvveeeedddd[[[[2222]]]];;;;
  21.      }}}} ppppmmmm____ppppggggiiiinnnnffffoooo____tttt;;;;
  22.  
  23.      iiiinnnntttt ________ppppmmmm____ggggeeeetttt____ppppaaaaggggeeee____iiiinnnnffffoooo((((vvvvooooiiiidddd ****bbbbaaaasssseeee____aaaaddddddddrrrr,,,,
  24.                             ssssiiiizzzzeeee____tttt lllleeeennnnggggtttthhhh,,,,
  25.                             ppppmmmm____ppppggggiiiinnnnffffoooo____tttt**** ppppggggiiiinnnnffffoooo____bbbbuuuuffff,,,,
  26.                             iiiinnnntttt bbbbuuuuffff____lllleeeennnn))))
  27.  
  28.      ddddeeeevvvv____tttt ________mmmmlllldddd____ttttoooo____nnnnooooddddeeee((((ppppmmmmoooo____hhhhaaaannnnddddlllleeee____tttt mmmmlllldddd____hhhhaaaannnnddddlllleeee))))
  29.  
  30.  
  31. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  32.      The above two interfaces can be used to get placement information of a
  33.      process's address space. It has to be done from the context of that
  34.      process.
  35.  
  36.      ___________pppp_mmmm______gggg_eeee_tttt______pppp_aaaa_gggg_eeee______iiii_nnnn_ffff_oooo takes an address range in terms of base_addr and
  37.      length. pginfo_buf is an array of pm_pginfo_t structures passed by the
  38.      caller. On completion of the system call pginfo_buf contains the
  39.      placement information for every page in the address range that has been
  40.      faulted in. The vaddr field of pm_pginfo_t contains the virtual address
  41.      of the page, node_dev contains the hardware graph dev_t of the node where
  42.      the page has been placed. page_size is the page size used while mapping
  43.      that virtual address. pm_handle is the handle of the pm that is attached
  44.      to that virtual address. From dev_t one can get the hardware graph device
  45.      name by using the libc routine dev_to_devname. If a page in the virtual
  46.      address range has not been faulted in there is no corresponding entry in
  47.      the pginfo_buf. If there is no error the return value contains the number
  48.      of entries in the buffer that have been filled by the kernel.
  49.  
  50.      ___________mmmm_llll_dddd______tttt_oooo______nnnn_oooo_dddd_eeee converts an mld to the node where the mld has been placed.
  51.      It returns the hardware graph dev_t of the node. The hardware graph name
  52.      can be found by using the library routine dev_to_devname(2).
  53.  
  54. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  55.      numa(5), mmci(5), mld(3c), mldset(3c), pm(3c), migration(3c),
  56.      dev_to_devname(2)
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ppppmmmmiiiinnnnffffoooo((((3333))))                                                            ppppmmmmiiiinnnnffffoooo((((3333))))
  71.  
  72.  
  73.  
  74. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  75.      Returns -1 on error.
  76.  
  77.      ___________pppp_mmmm______gggg_eeee_tttt______pppp_aaaa_gggg_eeee______iiii_nnnn_ffff_oooo will fail and the pm_pginfo_t structure will not be
  78.      filled in if one or more of the following are true:
  79.  
  80.      _EEEE_FFFF_AAAA_UUUU_LLLL_TTTT         Arguments could not be copied into or out of kernel space.
  81.  
  82.      _EEEE_FFFF_AAAA_UUUU_LLLL_TTTT         pginfo_buf address does not exist in the address space.
  83.  
  84.      _EEEE_IIII_NNNN_VVVV_AAAA_LLLL         If the number of elements in the pginfo is < 1.
  85.  
  86.      _EEEE_IIII_NNNN_VVVV_AAAA_LLLL         If the _bbbb_aaaa_ssss_eeee______aaaa_dddd_dddd_rrrr plus the _llll_eeee_nnnn_gggg_tttt_hhhh results in an overflow
  87.                     condition that produces an ending address that is less
  88.                     that the _bbbb_aaaa_ssss_eeee______aaaa_dddd_dddd_rrrr.
  89.  
  90.      _EEEE_2222_BBBB_IIII_GGGG          If the number of elements > 1024.
  91.  
  92.      ___________mmmm_llll_dddd______tttt_oooo______nnnn_oooo_dddd_eeee will fail and return an error if one or more of the
  93.      following is true:
  94.  
  95.      _EEEE_IIII_NNNN_VVVV_AAAA_LLLL         The MLD handle does not exist or is invalid.
  96.  
  97. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  98.           #include <sys/types.h>
  99.           #include <sys/pmo.h>
  100.           #include <sys/attributes.h>
  101.           #include <sys/conf.h>
  102.           #include <sys/hwgraph.h>
  103.           #include <sys/stat.h>
  104.           #include <invent.h>
  105.           #include <stdio.h>
  106.           #include <stdlib.h>
  107.           #include <string.h>
  108.  
  109.           #define NUMNODES        100
  110.           #define NBPP            16384
  111.           #define STACK_SIZE      20*NBPP
  112.           #define DATA_SIZE       20*NBPP
  113.  
  114.           char databuf[DATA_SIZE];
  115.  
  116.           pm_pginfo_t  node_buf[NUMNODES];
  117.  
  118.           void print_nodes(pm_pginfo_t *, int);
  119.           extern int __pm_get_page_info();
  120.  
  121.           void
  122.           main(int argc, char **argv)
  123.           {
  124.                   char    stkbuf[STACK_SIZE];
  125.                   int     ret;
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ppppmmmmiiiinnnnffffoooo((((3333))))                                                            ppppmmmmiiiinnnnffffoooo((((3333))))
  137.  
  138.  
  139.  
  140.                   volatile char   *addr;
  141.  
  142.  
  143.                   printf("addr %x len %x0,databuf, stkbuf - databuf + STACK_SIZE);
  144.                   addr = databuf;
  145.                   while (addr < (databuf + DATA_SIZE)) {
  146.                           *addr = 0;
  147.                           addr += NBPP;
  148.                   }
  149.  
  150.                   ret = __pm_get_page_info(0, 0x7fffffff, &node_buf, NUMNODES);
  151.                   printf("__pm_get_page_info returns ret %d0, ret);
  152.                   if (ret == -1) {
  153.                           perror("__pm_get_page_info");
  154.                           exit(1);
  155.                   }
  156.  
  157.                   printf("stack buf nodes0);
  158.                   print_nodes(node_buf, ret);
  159.  
  160.                   ret = __pm_get_page_info(databuf, sizeof(databuf), &node_buf, NUMNODES);
  161.                   printf("__pm_get_page_info returns ret %d0, ret);
  162.                   if (ret == -1) {
  163.                           perror("__pm_get_page_info");
  164.                           exit(1);
  165.                   }
  166.                   printf("data buf nodes0);
  167.                   print_nodes(node_buf, ret);
  168.           }
  169.  
  170.           void
  171.           print_nodes(pm_pginfo_t *nbuf, int numnodes)
  172.           {
  173.                   int     i;
  174.                   char    devname[160];
  175.                   int     length;
  176.  
  177.  
  178.                   for (i = 0; i < numnodes; i++) {
  179.                           length = sizeof(devname);
  180.                           printf("Address %x devt %x node %s page size %d pm %d0,
  181.                                   nbuf[i].vaddr,
  182.                                   nbuf[i].node_dev,
  183.                                   dev_to_devname(nbuf[i].node_dev,  devname, &length),
  184.                                   nbuf[i].page_size,
  185.                                   nbuf[i].pm_handle);
  186.                   }
  187.           }
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ppppmmmmiiiinnnnffffoooo((((3333))))                                                            ppppmmmmiiiinnnnffffoooo((((3333))))
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                                                                         PPPPaaaaggggeeee 4444
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.